library(ggplot2)
library(palmerpenguins)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
penguin_colors = c("darkorange","purple","cyan4")


fig <- plot_ly(data = penguins, x = ~flipper_length_mm, y = ~bill_length_mm, type = "scatter", color = ~species, colors = penguin_colors)

fig
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
## Warning: Ignoring 2 observations
# scatterplot with more customization
fig <- plot_ly(data = penguins, x = ~flipper_length_mm, y = ~bill_length_mm, color = ~species, colors = penguin_colors,
               mode = "markers", symbol = ~species, symbols = c("circle","triangle-up","square"), size = 10)

fig
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## Warning: Ignoring 2 observations
p <- ggplot(data = penguins,aes(x = flipper_length_mm, 
                           y = bill_length_mm)) +
  geom_point(aes(color = species, 
                 shape = species,
                 alpha = 0.8)) +
  scale_color_manual(values = c("darkorange","purple","cyan4")) +
  scale_alpha(guide = 'none') +
  labs(title = "Flipper and bill length",
       subtitle = "Dimensions for Adelie, Chinstrap and Gentoo Penguins at Palmer Station LTER",
       x = "Flipper length (mm)",
       y = "Bill length (mm)",
       color = "Penguin species",
       shape = "Penguin species") +
  theme_bw()

ggplotly(p)